package com.ty.day3.home;

import java.util.Random;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/16 18:09
 */
public class Sum {
    public static void main(String[] args) {
        int[][] a = new int[9][9];
        int sum=0;
        Random random = new Random();
        for (int i = 0; i < a.length; i++){
            for (int j = 0; j < a[i].length; j++) {
                a[i][j] = random.nextInt(100);
                System.out.print(a[i][j]+"\t");
            }
            System.out.println();
        }
        for (int i = 0; i < a.length; i++){
            sum += a[i][i];
        }
        System.out.println("对角线和:"+sum);
    }
}
